package com.example.a2209_shop.fg

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import com.example.a2209_shop.R
import com.example.a2209_shop.adapter.OrderAdapter
import com.example.a2209_shop.database.DataBaseUtils
import com.example.a2209_shop.databinding.FragmentPayingBinding
import com.example.base.mvvm.BaseViewFragment

/**
 * 查询待付款的订单
 */
class PayingFragment : BaseViewFragment<FragmentPayingBinding>() {
    lateinit var orderAdapter: OrderAdapter
    override fun initData() {
    }

    override fun initView() {
        orderAdapter = OrderAdapter()
        binding.rv.adapter = orderAdapter
        binding.rv.layoutManager = LinearLayoutManager(context)

        val list = DataBaseUtils.getDb().getOrderDao().queryOrderByStatus(2)
        orderAdapter.data.clear()
        orderAdapter.data.addAll(list)
        orderAdapter.notifyDataSetChanged()
    }

    override fun getLayout(): Int  = R.layout.fragment_paying

}